<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PDF Preview</title>
    <script src="../js/pdf.min.js"></script>
</head>
<body>
<h1>PDF Preview</h1>
<canvas id="pdfCanvas"></canvas>

<script>
    const url = "{{ fileUrl }}";  // 从后端传递的文件URL

    pdfjsLib.getDocument(url).promise.then(function(pdf) {
        pdf.getPage(1).then(function(page) {
            var scale = 1.5;
            var viewport = page.getViewport({ scale: scale });
            var canvas = document.getElementById('pdfCanvas');
            var context = canvas.getContext('2d');
            canvas.height = viewport.height;
            canvas.width = viewport.width;

            page.render({ canvasContext: context, viewport: viewport });
        });
    });
</script>
</body>
</html>
